<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Thu, 1 Jan 1970 01:00:00 GMT"); // Date in the past
error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
ini_set("display_errors","true");

chdir("../");
include_once("file.common.php");

$name = req('name', '.');
$callback = req('callback');

if ($callback)
	header('Content-type: text/JavaScript');
else
	header('Content-type: application/json');
$result = false;
$ee = '';
$filePath = "../../spaces/" . $name;

//$exclude = ",nathan,natalie,frankie,persephone,darcy,shallon,lesley,";
$exclude = ",space,spaces,page,pages,data,root,app,scripts,fuck,shit,crap,cunt,bitch,whore,sex,";

if (strpos($exclude, ",$name,") !== FALSE)
	$result = FALSE;
else if (strpos($name, "test") !== FALSE && $name != "testspace72")
	$result = FALSE;
else
	$result = !file_exists($filePath);	

if ($callback)
	$ee .= "$callback({\n";
else
	$ee .= "{\n";
$ee .= '"result":' . json_encode($result) . ",\n";
$ee .= '"end":true' . "\n";
if ($callback)
	$ee .= "})";
else
	$ee .= "}";
echo $ee;

?>